This is a simple x and y-axis PID controller made with planck.js (a JS physics engine). The idea is based on an article by Vazgriz about PID Controllers in Unity3D. The article gives a practical explanation on proportional, integral and derivative control. The cool thing about all this is that you will need very little code (pid-controller.js).
- 30 pixels is a meter
- The blue box itself is 1 by 1 meter with a mass of 1 kg
- Plane is frictionless
- Forces are applied on the blue box to find the target
- The P, I, D are tunable through a menu
git clone https://robinkrens.nl/repo/xy-pid-controller
Checkout the following demo to tune PID values and see the real time effects!